Java Applets: Web 2.0’s retarted step-child

They are still supported but Sun’s documentation has gone to pot. There’s almost nothing out there describing implementing applets with Java SE 6. Sure there are a lot of examples with 1.4, but the world has changed modern browsers and W3C have deprecated the applet tag, and if you’re trying to do something like interact with your applet via javascript there’s almost nothing discussing this and of course the old Applet tag is broken in “Modern” browsers, and although there are 20 examples they all seem to be toys with respect to Web 2.0, namely they are still using the applet tag, thanks for coming out.

Here’s what I’ve come up with for embedding applets and interacting with them via javascript, it’s a bit hackish but it has the cleanest/simplest code I could come up with.

    <!–[if !IE]> Firefox and others will use outer object –>
    <embed type=”application/x-java-applet”
           name=”mac_address_applet”
           width=”0″
           height=”0″
           code=”com.yourco.MacAddressApplet”
           archive=”macaddress.jar”
           pluginspage=”http://java.sun.com/javase/downloads/index.jsp”
           style=”position:absolute; top:-1000px; left:-1000px;”>
        <noembed>
        <!–<![endif]–>
            <!—->
            <object classid=”clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA”
type=”application/x-java-applet”
name=”mac_address_applet”
style=”position:absolute; top:-1000px; left:-1000px;”
                    >
                <param name=”code” value=”com.yourco.MacAddressApplet”>
                <param name=”archive” value=”macaddress.jar” >
                <param name=”mayscript” value=”true”>
                <param name=”scriptable” value=”true”>
                <param name=”width” value=”0″>
                <param name=”height” value=”0″>
              </object>
        <!–[if !IE]> Firefox and others will use outer object –>
        </noembed>
    </embed>
    <!–<![endif]–>

Once I’ve repackaged the applet which “sniffs” the first MAC Address of any interface on your machine, which I guess could come in handy from time to time.

Leave a Reply